<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var menu = document.querySelector(".title")
        var liElm = document.querySelector(".list")
        var lisElm = document.querySelectorAll(".list li")
        var i = 0;
        menu.onclick = function () {
            i++
            if (i % 2 == 0) {
                liElm.style.display = "none";
            } else {
                liElm.style.display = "block";
            }
        }
        lisElm.forEach(function (value, key) {
            value.onclick = function () {
                menu.innerHTML = value.innerHTML;
                liElm.style.display = "none";   // 点完后隐藏
                i = 0;  // 点完后i置0，不然下次再次选择要点两下
            }
        })
    </script>


</body>

</html>